'''
    @project: Masdevallia
    @author: Austin Baker
    @created: 2/22/2014
    @license: http://opensource.org/licenses/mit-license.php

    The MIT License (MIT)

    Copyright (c) 2014 Austin Baker
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
    
    About:
    Class for creating rig controls.
'''

'''
============================================================
--->>   IMPORT MODULES
============================================================
'''
import maya.OpenMaya as OpenMaya
import masdevallia.utility.Dag as Dag
import masdevallia.nodes.Node as Node
import masdevallia.utility.Matrix as Matrix
import masdevallia.utility.XML as XML
import masdevallia.utility.Colors as Colors

'''
============================================================
--->>   RIG CONTROL CLASS
============================================================
'''
class RigControl( object ):
    '''
    Base class for rig controls.
    '''
    def __init__( self, inObj=None ):
        if isinstance( inObj, str ) or isinstance( inObj, OpenMaya.MObject ) or inObj is None:
            self.name = inObj
            self.fullname = None
            self.asMObject = None
            self.asDagPath = None
            self.matrixData = None
            self.color = 1
            self.shape = None
            self.prefix = 'ct'
            self.spacer = None
            
            if inObj:
                self.updateClassAttributes()
        else:
            OpenMaya.MGlobal.displayError( 'RigControl argument inObj is not a string or MObject. {0}'.format( type( inObj ) ) )
    
    def updateClassAttributes( self ):
        '''
        Fills the class attributes. Only applicable if the joint already exists.
        '''
        if Dag.objExists( self.name ):            
            # Node attributes.
            self.fullname = Dag.getPathname( self.name, inFull=True )
            self.asMObject = Dag.getMObject( self.name )
            self.asDagPath = Dag.getDagPath( self.name )
            self.matrixData = Matrix.Matrix( self.fullname, 'worldMatrix' )
            
            # TODO
            self.color = None
            self.shape = None
            self.prefix = 'ct'
            self.spacer = None
        
    '''
    Override functions
    '''
    def create(self):
        pass

    def createCompoundControl(self):
        pass
    
    def setColor(self):
        Colors.setObjectDormantColor( inObject=self.fullname, inColorID=self.color )
        
    def getColor(self):
        pass
    
    def save(self):
        pass
    
    def load(self):
        pass
    
    def shader(self):
        pass
    
    '''
    Utility
    '''           
    def createSpacer(self):
        pass


